﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using YUCodeGen.Models;
using YUCodeGen.ProductModel;

namespace YUCodeGen.Controllers
{
    
    public class StudentController : ApiController
    {
        [HttpPost]
        [Route("api/studentlist")]
        public DataTableResponse GetAll([FromBody] object para)
        {
            var data = new List<Student>() {
                new Student{
                    Name="曹操", Phone="18888883333",Birthday = DateTime.Parse("2001-01-01"),Address="北京市朝阳区酒仙桥", Email="caocao.qq.com"
                },
                new Student{
                    Name="王景辉", Phone="18888883332",Birthday = DateTime.Parse("2001-01-01"),Address="北京市朝阳区酒仙桥", Email="caocao.qq.com"
                },
                new Student{
                    Name="孙权", Phone="18888883331",Birthday = DateTime.Parse("2001-01-01"),Address="北京市朝阳区酒仙桥", Email="caocao.qq.com"
                },
                new Student{
                    Name="秦琼", Phone="188888833000",Birthday = DateTime.Parse("2001-01-01"),Address="北京市朝阳区酒仙桥", Email="caocao.qq.com"
                },
                new Student{
                    Name="张作霖", Phone="1888885999",Birthday = DateTime.Parse("2001-01-01"),Address="北京市朝阳区酒仙桥", Email="caocao.qq.com"
                }
            };

            return new DataTableResponse
            {
                recordsFiltered = 5, recordsTotal = 5, data = data.Cast<object>()
            };
        }
        [HttpPost]
        public Student Save(Student student)
        {
            return student as Student;
        }
    }
}
